home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / prog / graphics / draw.c < prev    next >
C/C++ Source or Header  |  1994-08-05  |  2KB  |  80 lines

  1. #include <LEDA/plane.h>
  2. #include <LEDA/window.h>
  3.  
  4. main()
  5. {
  6.   window W;
  7.  
  8.   line_style lstyle = solid;
  9.   int        lwidth = 1;
  10.   color      col    = black;
  11.   bool       fill   = false;
  12.  
  13.   panel P("DRAW");
  14.  
  15.   P.bool_item  ("fill",fill);
  16.   P.color_item ("color",col);
  17.   P.lstyle_item("line style",lstyle);
  18.   P.int_item   ("line width",lwidth,1,10);
  19.  
  20.   P.button("point");
  21.   P.button("segment");
  22.   P.button("line");
  23.   P.button("circle");
  24.   P.button("poly");
  25.   P.new_button_line();
  26.   P.button("clear");
  27.   P.button("continue");
  28.   P.button("quit");
  29.  
  30.   int but = 5;
  31.  
  32.   for(;;)
  33.   {
  34.     int i = P.open(W);
  35.  
  36.     W.set_line_width(lwidth);
  37.     W.set_line_style(lstyle);
  38.  
  39.     if (i!=6) but = i;
  40.  
  41.     switch(but) {
  42.  
  43.  
  44.     case 0: { point p;
  45.               while (W >> p)  W.draw_point(p,col);
  46.               break;
  47.              }
  48.     case 1: { segment s;
  49.               while (W >> s)  W.draw_segment(s,col);
  50.               break;
  51.              }
  52.     case 2: { line l;
  53.               while (W >> l)  W.draw_line(l,col);
  54.               break;
  55.              }
  56.     case 3: { circle c;
  57.               while (W >> c)  
  58.                 if (fill) W.draw_disc(c,col);
  59.                 else      W.draw_circle(c,col);
  60.               break;
  61.              }
  62.     case 4: { polygon P;
  63.               while (W >> P)  
  64.                 if (fill) W.draw_filled_polygon(P,col);
  65.                 else      W.draw_polygon(P,col);
  66.               break;
  67.              }
  68.  
  69.     case 5: W.clear();
  70.             break;
  71.  
  72.     case 7: exit(0);
  73.  
  74.     }
  75.  
  76.   }
  77.  
  78.   return 0;
  79. }
  80.